import React from 'react';
import { Router, Route, Switch } from 'dva/router';
import IndexPage from './routes/IndexPage';
import ModulePage from './routes/ModulePage';

const cached = {};
function registerModel(app, model) {
  if (!cached[model.namespace]) {
    app.model(model);
    cached[model.namespace] = 1;
  }
}

function RouterConfig({ history }) {
  // const routes = [
  //   {
  //     path: '/',
  //     name: 'IndexPage',
  //     getComponent(location, callback) {
  //       require.ensure([], (require) => {
  //         callback(null, require('./routes/IndexPage'));
  //       });
  //     },
  //   }
  // ];
  // const router = (<Router history={history} routes={routes} />);
  // console.log(router);
  // return router;

  const router = (
    <Router history={history}>
      <Switch>
        <Route path="/" exact component={IndexPage} />
        <Route path="/module" exact component={ModulePage} />
      </Switch>
    </Router>
  ) ;
  console.log(router);
  return router

};

export default RouterConfig;
